package cn.simon.service;

import cn.simon.mapper.OrdersMapper;
import cn.simon.model.Orders;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrdersService {
    @Autowired
    private OrdersMapper ordersMapper;

    public List<Orders> getOrderAll(Page<Orders> page){

        return ordersMapper.getOrderAll(page);
    }
    public List<Orders> getSellerOrder(Page<Orders> page,Integer sellerId,Integer state){

    return ordersMapper.getSellerOrder(page,sellerId,state);
    }

    public int setByState(Orders orders){
        return ordersMapper.updateByPrimaryKeySelective(orders);
    }


    public List<Orders> getUserOrder(Page page,Integer userId){
        return ordersMapper.getOrderByUserId(page,userId);
    }

    /**
     * 生成订单
     * @param order
     * @return
     * @author Kinfer
     * @date 2022/0/28
     */
    public int addOrder(Orders order) {
        ordersMapper.insert(order);
        return 1;
    }
}
